<template>
  <div>
    <h1>商家管理</h1>
    <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="storeId" label="商家编号" width="180"></el-table-column>
      <el-table-column prop="storeName" label="店铺名称" width="180"></el-table-column>
      <el-table-column prop="userName" label="名称" width="180"></el-table-column>
<!--      <el-table-column prop="storeState" label="商家状态" width="180"></el-table-column>-->
<!--      <el-table-column prop="storePwd" label="商家密码" width="180"></el-table-column>-->
<!--      <el-table-column prop="storeTel" label="商家手机号" width="180"></el-table-column>-->
<!--      <el-table-column prop="storeCode" label="商家验证码" width="180"></el-table-column>-->
<!--      <el-table-column prop="userId" label="编号" width="180"></el-table-column>-->
<!--      <el-table-column prop="userRole" label="角色" width="180"></el-table-column>-->
<!--      <el-table-column prop="deleted" label="日期" width="180"></el-table-column>-->
      <el-table-column prop="createTime" label="创建日期" width="180"></el-table-column>
      <el-table-column prop="updateTime" label="最后修改日期" width="180"></el-table-column>
      <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button size="mini" @click="handleEdit(scope.row.storeId)">显示商品</el-button>
<!--            <el-button size="mini" type="danger" @click="handleDelete(scope.row.storeId)">删除</el-button>-->
          </template>
      </el-table-column>
    </el-table>
    <div class="block">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="storelist.page"
        :page-sizes="[1, 3, 6, 9]"
        :page-size="storelist.size"
        layout="total, sizes, prev, pager, next, jumper"
        :total="storelist.total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
  import axios from 'axios'
  export default {
    name: 'Index',
    data(){
        return{
          tableData:[],
          storelist:{page:1,size:3,total:0},
          userRole:''
        }
    },
    methods:{
        getlist(){
          let userName= sessionStorage.getItem("userName")
          console.log(userName)
          let userId= sessionStorage.getItem("userId")
          console.log(userId)
          let userRole= sessionStorage.getItem("userRole")
          this.userRole=userRole
          console.log(userRole)
          var us= new FormData();
          us.append("page",this.storelist.page)
          us.append("size",this.storelist.size)
          us.append("total",this.storelist.total)
          us.append("userName",userName)
          us.append("userId",userId)
          us.append("userRole",userRole)
          axios.post("http://localhost:7000/shop/store/rolelist",us,this.storelist).then(res=>{
            console.log(us)
            console.log(res)
            this.storelist.total=res.data.data.total
            this.tableData=res.data.data.records
          })
        },
      handleSizeChange(val) {
          this.storelist.size=val
          console.log(`每页 ${val} 条`);
          this.getlist()
      },
      handleCurrentChange(val) {
          this.storelist.page=val
          console.log(`当前页: ${val}`);
          this.getlist()
      },
      handleEdit(storeId) {
        console.log(storeId);
        sessionStorage.setItem("storeId",storeId)
        this.$router.push("goods")
      },
      handleDelete(storeId) {
        console.log(storeId);
      }
    },
    mounted() {
        this.getlist()
    }
  }
</script>

<style scoped></style>
